year=eval(input())
month=eval(input())
day=eval(input())
if (year%4==0 and year%100!=0)or(year%400==0):
    isleap=1;
else:
    isleap=0;
list=[31,28+isleap,31,30,31,30,31,31,30,31,30,31]
i=0
days=0
while (i+1)<month:
    days=days+list[i]
    i+=1
days=days+day
print(days)